package com.bottomlord.configuration.microprofile.config.converter;

import org.eclipse.microprofile.config.spi.Converter;

/**
 * {@link Class} {@link Converter} implementation
 * @author ChenYue
 * @date 2021/5/13 10:21
 */
public class ClassConverter extends AbstractConverter<Class> {

    private final ClassLoader classLoader;

    public ClassConverter() {
        this(Thread.currentThread().getContextClassLoader());
    }

    public ClassConverter(ClassLoader classLoader) {
        this.classLoader = classLoader;
    }

    @Override
    protected Class doConvert(String value) throws Throwable {
        return classLoader.loadClass(value);
    }
}
